<?

		$sql['order'] = "substring(imagetaken,1,4) desc, ".$sql['order'];
		
		if (strpos($sql['columns'], ",imagetaken") === FALSE) {
			$sql['columns'] .= ",imagetaken";
		} 
		function searchbreak(&$c,$start='',$end='') {
			static $last;

			if (empty($c)) {//its the last one
				if ($last) {
					print $end;
				}
				return;
			}
			
			$y = substr($c['imagetaken'],0,4);
			
			if ($y != $last) {
				if ($last) {
					print $end;
				}
				
				print "<h4>Year $y";
				if (empty($_GET['taken']) || $_GET['taken'] != $y) 
					print " (<a href=\"".linktoself(array('taken'=>$y,'delete'=>array('opt','page')))."\">Show only</a>)";
				print "</h4>";
				print $start;
			}
			
			$last = $y;
			return true; //we dont disable any images...
		}
		
		$opt['opt'] = 'byyear';